function cut_str(str,start,end){
    if(str.length>=end && start>=0){
        str1=str.substring(start,end);
    }
    return str1;
}
$(".no").on("click",function(){
    location.href="/teacher/backHomePage.do";
})
$(".yes").on("click",function(){
    if(confirm("确定要添加吗？")){
        var name=$(".nameText").val();
        var age=$(".ageText").val();
        var phone=$(".phoneText").val();
        var creatTime=$(".timeText").val();
        if($(".sex select").val()==1){
            var sex="男";
        }else{
            var sex="女";
        }
        var class_id=$(".class select").val();
        var create_time=cut_str(creatTime,0,10)+" "+cut_str(creatTime,11,16)+":00";
        $.ajax({
            url:"/teacher/addTeacher.do",
            type:"post",
            data:{
                name:name,
                age:age,
                sex:sex,
                create_time:create_time,
                phone:phone,
            },
            success:function(value){
                console.log(value);
                if(value==1){
                    alert("添加成功！");
                }
            },
            error:function (){
                alert("添加失败！");
            }
        })
    }
})